package com.codedancer.campus.mapper;

import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.codedancer.campus.common.core.BaseMapper;
import com.codedancer.campus.po.CircleExamineRecord;
import java.util.List;

public interface CircleExamineRecordMapper extends BaseMapper<CircleExamineRecord> {

    /**
     * 查询最近一条审核记录
     *
     * @param uuid
     * @return
     */
    default CircleExamineRecord selectLatestExamineRecord(String uuid) {
        LambdaQueryWrapper<CircleExamineRecord> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        lambdaQueryWrapper.eq(CircleExamineRecord::getCircleUuid, uuid);
        lambdaQueryWrapper.orderByDesc(CircleExamineRecord::getCreateTime);
        return CollectionUtil.isNotEmpty(selectList(lambdaQueryWrapper)) ? selectList(
            lambdaQueryWrapper).get(0) : null;
    }

    /**
     * 查询圈子审核记录
     *
     * @param circleUuid
     * @return
     */
    default List<CircleExamineRecord> list(String circleUuid) {
        LambdaQueryWrapper<CircleExamineRecord> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        lambdaQueryWrapper.eq(CircleExamineRecord::getCircleUuid, circleUuid);
        return selectList(lambdaQueryWrapper);
    }
}
